jQuery(document).ready(function($) {
    var b = $("#sign");
    $("#register-active").on("click", function() {
        b.removeClass("sign").addClass("register");
    }), $("#login-active").on("click", function() {
        b.removeClass("register").addClass("sign");
    }), $(".user-login,.user-reg").on("click", function(c) {
        $("div.overlay").length <= 0 ? $(".header-wrap").before('<div class="overlay"></div>') : $("div.overlay").show(), $("body").addClass("fadeIn"), 1 == $(this).attr("data-sign") ? b.removeClass("sign").addClass("register") : b.removeClass("register").addClass("sign"), $("div.overlay, form a.close").on("click", function() {
            return $("body").removeClass("fadeIn"), b.removeAttr("class"), $("div.overlay").remove(), !1;
        }), c.preventDefault();
    }), $("form#login, form#register").on("submit", function(b) {
        return $(this).valid() ? ($("p.status", this).show().text(ajax_sign_object.loadingmessage), "login" == $(this).attr("id") ? (action = "login", username = $("form#login #username").val(), password = $("form#login #password").val(), email = "", remember = "checked" == $("#rememberme").attr("checked") ? $("form#login #rememberme").val() : "", $("form#login .submit").attr("disabled", !0).addClass("disabled").val("登录中...")) : "register" == $(this).attr("id") && (action = "regist", username = $("#user_name").val(), password = $("#user_pass").val(), email = $("#user_email").val(), remember = "", $("form#register .submit").attr("disabled", !0).addClass("disabled").val("注册中...")), _this = $(this), a.ajax({
            type: "POST",
            dataType: "json",
            url: ajax_sign_object.ajaxurl,
            data: {
                action: action,
                username: username,
                password: password,
                email: email,
                remember: remember
            },
            success: function(b) {
                $("p.status", _this).html(b.message), 1 == b.loggedin && (document.location.href = ajax_sign_object.redirecturl);
            },
            complete: function() {
                $("form#login .submit").removeAttr("disabled").removeClass("disabled").val("登录"), $("form#register .submit").removeAttr("disabled").removeClass("disabled").val("注册");
            }
        }), b.preventDefault(), void 0) : !1;
    }), jQuery.validator.addMethod("isEnglish", function(a, b) {
        return this.optional(b) || /^[a-zA-Z][A-Za-z0-9_]+$/.test(a);
    }, "只允许英文开头字符可加数字"), jQuery("#login").length && jQuery("#login").validate({
        rules: {
            username: {
                required: !0,
                minlength: 2
            },
            password: {
                required: !0,
                minlength: 6
            }
        },
        messages: {
            username: {
                required: "请输入用户名",
                minlength: a.validator.format("用户名不能少于{0}个字符")
            },
            password: {
                required: "请输入密码",
                minlength: a.validator.format("密码不能小于{0}个字符")
            }
        }
    }), jQuery("#register").length && jQuery("#register").validate({
        rules: {
            user_name: {
                required: !0,
                isEnglish: !0,
                minlength: 3,
                maxlength: 15
            },
            user_email: {
                required: !0,
                email: !0
            },
            user_pass: {
                required: !0,
                minlength: 6
            },
            user_pass2: {
                required: !0,
                minlength: 6,
                equalTo: "#user_pass"
            }
        },
        messages: {
            user_name: {
                required: "请输入英文用户名",
                minlength: a.validator.format("用户名不能少于{0}个字符"),
                maxlength: a.validator.format("用户名不能多于{0}个字符")
            }
            user_email: {
                required: "请输入Email地址",
                email: "请输入正确的email地址"
            },
            user_pass: {
                required: "请输入密码",
                minlength: a.validator.format("密码不能小于{0}个字符")
            },
            user_pass2: {
                required: "请输入确认密码",
                minlength: a.validator.format("确认密码不能小于{0}个字符"),
                equalTo: "两次输入的密码不一致"
            }
        }
    });
})